<template>
	<view class="confirm-pay">
		<view class="title">
			<text>确认支付</text>
			<text class="iconfont1 icon-guanbi1 close" @click="$emit('closePop')"></text>
		</view>
		<view class="content">
			<view class="content-left">
				<image :src="$util.img(zfData.list_img)" mode="aspectFill"></image>
			</view>
			<view class="content-right">
				<view class="name">{{zfData.title}}</view>
				<view class="des">魔力福袋商品不支持7天无理由退款希望您能理解
				</view>
				<view class="price">
					<view class="price-content">
						<view class="label"></view>
						<view class="value">
							<!-- <text>¥</text> -->
							<text>{{price}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="bottom">
			<view class="protocol">
				<view class="text" @click="goRule">
					<text>同意</text>
					<text>《魔力福袋买家须知》</text>
				</view>
				<checkbox class="btn" :checked="isChecked" @click="isChecked=!isChecked" />
			</view>
		</view>
		<button :class="['go-buy',{active:isChecked}]" @click="goPay">立即支付</button>
	</view>
</template>

<script>
	export default {
		props: {
			zfData: {
				type: Object
			},
			payType: {
				type: String | Number
			}
		},
		data() {
			return {
				isChecked: false
			}
		},
		computed: {
			price() {
				if(this.zfData.box_coupon_id>0&&this.payType==1){
					return this.zfData.newprice;
				}
				if(this.zfData.box_coupon_id>0&&this.payType==5){
					return this.zfData.newfiveprice;
				}
				return (this.zfData.price * Number(this.payType)).toFixed(2);
			}
		},
		methods: {
			goPay() {
				if (!this.isChecked) {
					uni.showToast({
						title: '请仔细阅读并勾选相关协议',
						icon: 'none'
					})
					return;
				}
				this.$emit("confirm");
			},
			goRule() {
				this.$util.redirectTo('/pages/magic-box/rule/index', {
					url: '/api/protocal/servicehelp.html'
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.confirm-pay {
		width: 100%;
		border-top-left-radius: 45rpx;
		border-top-right-radius: 45rpx;
		padding: 0 22rpx;
		box-sizing: border-box;

		.title {
			font-size: 31rpx;
			font-family: Source Han Sans CN;
			font-weight: 500;
			color: #111111;
			position: relative;
			// height: 85rpx;
			padding: 40rpx 0;
			// line-height: 85rpx;
			text-align: center;

			.close {
				position: absolute;
				top: 42rpx;
				right: 0;
				line-height: initial;
				font-size: 40rpx;
			}
		}

		.content {
			display: flex;

			.content-left {
				width: 167rpx;
				height: 167rpx;
				flex-shrink: 0;

				&>image {
					width: 100%;
					height: 100%;
				}
			}

			.content-right {
				flex: 1;
				margin-left: 27rpx;

				.name {
					font-size: 30rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					margin-bottom: 26rpx;
					color: #111111;
					width: 100%;
					text-overflow: ellipsis;
					overflow: hidden;
					display: -webkit-box; //弹性盒模型
					-webkit-box-orient: vertical; //上下垂直
					-webkit-line-clamp: 2; //自定义行数
				}

				.des {
					font-size: 24rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: rgba(35, 35, 35, 0.6);
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
					line-height: initial;
					height: 64rpx;
				}

				.price {
					display: flex;
					justify-content: center;
					align-items: center;
					font-weight: bold;

					.price-content {
						flex: 1;

						margin-top: 18rpx;
						display: flex;
						align-items: center;

						.label {
							width: 36rpx;
							height: 40rpx;
							background: url(../../../../static/image/money.png);
							background-size: 100% 100%;
						}

						.value {
							line-height: 0;
							color: #FF0036;

							// &>text:nth-of-type(1) {
							// 	font-size: 26rpx;
							// 	padding-right: 5rpx;
							// }

							&>text:nth-of-type(1) {
								font-size: 36rpx;
							}
						}

					}
				}

			}
		}

		.bottom {
			padding: 0 22rpx;
			box-sizing: border-box;

			.protocol {
				display: flex;
				justify-content: space-between;
				margin-top: 42rpx;

				&>.text {
					font-size: 25rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;

					&>text:nth-of-type(1) {
						color: #232323;
					}

					&>text:nth-of-type(2) {
						color: #6C20FF;
					}
				}

				.btn {
					/deep/ .uni-checkbox-wrapper {
						.uni-checkbox-input {
							width: 39rpx;
							height: 39rpx;
							border-radius: 50%;
							border: 1px solid #04070A !important;
						}

						.uni-checkbox-input-checked {
							color: #6E24FF !important;
							border: 1px solid #6E24FF !important;
						}
					}

					// color: #6E24FF;
					// 
				}
			}


		}

		.go-buy {
			width: 100%;
			height: 98rpx;
			line-height: 98rpx;
			margin: 40rpx auto 31rpx;
			background: #CDCDCD;
			border-radius: 11rpx;
			font-size: 28rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #FFFFFF;
			padding: 0;
			box-sizing: border-box;

			&.active {
				background: linear-gradient(90deg, #5F20FF 0%, #1AD7FF 100%)
				// background: url(@/static/image/pay-button-bg.png);
				// background-size: 100% 100%;
			}
		}

	}
</style>
